/**
 * 为引入文件夹下所有组件 hook
 **/
export default function () {
  // 中横线转驼峰
  var camelCase = function (s) {
    return s.replace(/-\w/g, function (x) {
      return x.slice(1).toUpperCase();
    });
  };

  const allComponents = require.context(
    "@/views/login/components",
    false,
    /\.vue$/
  );

  // console.log(allComponents.keys())
  // ["./tem-a.vue", "./tem-b.vue", "./tem-c.vue", "./tem-d.vue"]

  // console.log(allComponents.id)
  //./src/views/tempManage/comp sync \.vue$
  //制作组件数组，在下方components中注册使用
  let resComponents = {};
  allComponents.keys().forEach((comName) => {
    let name = camelCase(comName);
    const comp = allComponents(comName);
    resComponents[name.replace(/^\.\/(.*)\.\w+$/, "$1")] = comp.default;
  });

  return resComponents;
}
